package org.neuedu.chapter10_0705.mydemo01;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Neuedu neuedu = new Neuedu();
        Scanner scanner = new Scanner(System.in);
        String info = null;
        while (true) {
            System.out.println("请选择以下学员操作:");
            System.out.println("1----增加学员");
            System.out.println("2----根据ID删除学员");
            System.out.println("3----根据ID修改学员");
            System.out.println("4----根据ID查询学员");
            System.out.println("5----查看学生列表信息");
            System.out.println("6----退出");
            String option = scanner.nextLine();
            switch (option) {
                case "1":
                    System.out.println("请输入学员信息(id,stuno,name,gender,age)");
                    info = scanner.nextLine();
                    String[] split = info.split(",");
                    Student stu = new Student();
                    stu.setId(Long.valueOf(split[0]));
                    stu.setStuno(Long.valueOf(split[1]));
                    stu.setName(split[2]);
                    stu.setGender(Boolean.valueOf(split[3]));
                    stu.setAge(Integer.valueOf(split[4]));
                    neuedu.addStudent(stu);
                    break;
                case "2":
                    System.out.println("请输入学员ID");
                    String strId = scanner.nextLine();
                    neuedu.delStudentById(Long.valueOf(strId));
                    break;
                case "3":
                    System.out.println("请输入要修改的学员信息(id,stuno,name,gender,age)");
                    info = scanner.nextLine();
                    String[] split1 = info.split(",");
                    Student stu1 = new Student();
                    stu1.setId(Long.valueOf(split1[0]));
                    stu1.setStuno(Long.valueOf(split1[1]));
                    stu1.setName(split1[2]);
                    stu1.setGender(Boolean.valueOf(split1[3]));
                    stu1.setAge(Integer.valueOf(split1[4]));
                    neuedu.updateInfoById(stu1);
                    break;
                case "4":
                    System.out.println("请输入学员ID");
                    String strId1 = scanner.nextLine();
                    Student info1 = neuedu.getInfoById(Long.valueOf(strId1));
                    System.out.println(info1);
                    break;
                case "5":
                    neuedu.showStuInfos();
                    break;
                case "6":
                    System.out.println("谢谢再见");
                    return;
                default:
                    System.out.println("请重新输入");
            }
        }
    }
}
